<template>
	<!-- <u-index-list :scrollTop="scrollTop" v-if="indexList.length">
		<view v-for="(item, index) in indexList" :key="index">
			<u-index-anchor :use-slot="true" :index="item">
				<text class="anchor-text">{{item}}</text>
			</u-index-anchor>
			
			<view v-for="(item1, index1) in listObj.list" class="list-cell" @click="listClist(item1)">
				<text>{{item1.ORMTB407CA01}}</text>
				<text>{{item1.ORMTB410CA02}}</text>
			</view>
		</view>
		
	</u-index-list> -->
	<view class="">
		<u-navbar title="通讯录" :background="background" title-color="#FFF" back-icon-color="#fff">
			<view class="navbar-right" slot="right">
				<view @click="addhyFun" class="tjhy-style">
					+添加好友
				</view>

			</view>
		</u-navbar>
		<view class="sousuo">
			<u-search placeholder="搜索好友名称或手机号" :show-action="false" @change="txlListFun" @search="txlListFun" v-model="keyword"></u-search>
		</view>
		<view class="" style="height:110rpx;">

		</view>
		<view class="">
			<uni-indexed-list :options="listObj.list" :show-select="false" @click="bindClick" />
		</view>
	</view>


</template>

<script>
	export default {
		data() {
			return {
				userinfo: JSON.parse(uni.getStorageSync('userinfo')),
				scrollTop: 0,
				// indexList: ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S",
				// 	"T", "U",
				// 	"V", "W", "X", "Y", "Z"
				// ],
				// list:[
				// 	{
				// 		key:'赵玉闯',

				// 	},
				// 	{
				// 		key:'朱盼',

				// 	}
				// ],
				listObj: {
					list: []
				},
				background: {
					backgroundColor: '#00a1f1',
				},
				keyword: ''


			}
		},
		onPageScroll(e) {
			this.scrollTop = e.scrollTop;
		},

		onLoad() {},
		onShow() {
			this.txlListFun()
		},
		methods: {

			bindClick(e) {
				console.log('点击item，返回数据' + JSON.stringify(e))
			},
			addhyFun() {
				uni.navigateTo({
					url: '/pages/daiOrde/tjhy/index'
				})
			},
			djxuanze() {
				console.log(1)
			},
			listClist(item) {
				console.log(item)
			},
			txlListFun() {
				uni.showLoading({
					title: '请求中...',
					mask: true
				});
				uni.request({
					url: this.baseUrl + '/orm/ormtb407/selectPageList',
					method: 'POST',
					dataType: 'json',
					data: {
						ORMTB410ID: this.userinfo.ORMTB410ID, //用户ID
						key: this.keyword //搜索内容
					},
					success: (res) => {
						uni.hideLoading();
						if (res.data.code == 200) {
							console.log(res)
							let arr = res.data.data
							// arr.forEach(item => {
							// 	// console.log(item)
							// 	// this.listObj.list.push({
							// 	// 	letter: item.letter

							// 	// })
							// 	item.data.forEach(item => {
							// 		console.log(item)
							// 		this.listObj.list.push({
							// 			data: item.ORMTB407CA01,
							// 			letter:'A'

							// 		})
							// 	})
							// })
							this.listObj.list = res.data.data
							console.log(this.listObj.list)
						} else {
							this.$refs.uToast.show({
								title: res.data.message,
								type: 'default',
								icon: false
							})
						}
					},
					fail: (res) => {
						uni.hideLoading();
						this.$refs.uToast.show({
							title: '服务器连接超时',
							type: 'default',
							icon: false
						})
					}
				});
			}
		}

	}
</script>

<style lang="scss" scoped>
	.list-cell {
		display: flex;
		box-sizing: border-box;
		width: 100%;
		padding: 10px 24rpx;
		overflow: hidden;
		color: #323233;
		font-size: 14px;
		line-height: 24px;
		background-color: #fff;
	}

	.sousuo {
		position: fixed;
		z-index: 999;
		width: 100%;
		padding: 20rpx;
	}

	.tjhy-style {
		color: #fff;
		background: #FF3300;
		border-radius: 10rpx;
		padding: 4rpx;
		margin-right: 10rpx;
	}
</style>